package assets_withdraw

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"
	"gitee.com/liuxuezhan/ar-platform/rpc-client/assetsClient/rpc"
	"github.com/jinzhu/copier"
	"github.com/zeromicro/go-zero/core/logx"
)

type UserAuthListPageLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// 会员管理--实名认证--查询
func NewUserAuthListPageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserAuthListPageLogic {
	return &UserAuthListPageLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserAuthListPageLogic) UserAuthListPage(req *types.UserAuthListPageReq) (resp *types.UserAuthListPageRes, err error) {
	rpc_req := &rpc.UserAuthListPageReq{}
	rpc_req.Page = &rpc.Pagination{}
	err = copier.Copy(&rpc_req.Page, req.Pagination)
	rpc_req.Data = &rpc.UserAuth{}
	err = copier.Copy(&rpc_req.Data, req.UserAuth)

	// 发送请求
	rpc_resp, err := l.svcCtx.AssetsRpc.PayWithdraw.UserAuthListPage(l.ctx, rpc_req)
	if err != nil {
		return nil, err
	}

	// 处理请求返回的结果
	// 解析、组合数据
	resp = &types.UserAuthListPageRes{}
	err = copier.Copy(&resp.Pagination, rpc_resp.Page)
	err = copier.Copy(&resp.Data, rpc_resp.Data)
	return
}
